"""
@Author:WKVugen
@Time:2023-06-28
@Description: 基础操作层
"""
from selenium import webdriver

from utils.config import Config


class BasePage:

    def __init__(self, driver):
        self.driver = driver
        # global driver
        # options = webdriver.ChromeOptions()
        # options.add_experimental_option("detach", True)  # 设置执行完后不关闭浏览器
        # self.driver = webdriver.Chrome(options=options)
        # driver = self.driver
        # # 打开招商后台系统
        # self.driver.get(self.url)
        # self.driver.maximize_window()



    def locator_element(self, loc):
        """
        定位元素的关键字
        :param loc:
        :return:
        """
        return self.driver.find_element(*loc)

    def locator_elements(self, loc):
        """
        定位一组元素
        :param loc:
        :return:
        """
        return self.driver.find_elements(*loc)

    def set_keys(self, loc, value):
        """
        设置值的关键字
        :param loc:
        :param value:
        :return:
        """
        self.locator_element(loc).send_keys(value)

    def click(self, loc):
        """
        点击的关键字
        :param loc:
        :return:
        """
        self.locator_element(loc).click()

    def get_value(self, loc):
        """
        判断获取与预期关键字
        :param loc:
        :return:
        """
        return self.locator_element(loc).text

    def clear(self, loc):
        """
        清空
        :param loc:
        :return:
        """
        self.locator_element(loc).clear()